package com.willcode.demo.orm.hibernate.controller;


import com.willcode.demo.orm.hibernate.entity.User;
import com.willcode.demo.orm.hibernate.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Will
 */
@RestController
@RequestMapping("springboot/hibernate")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping(path = "insert")
    public User insert(User user) {
        return userService.insert(user);
    }

    @RequestMapping(path = "findall",method = RequestMethod.GET)
    public List<User> findAll() {
        return userService.findAll();
    }

    @RequestMapping("findbyid")
    public User findById(String id) {
        return userService.findById(id);
    }
    @RequestMapping("find4link")
    public User find4Link(String id) {
        return userService.find4Link(id);
    }




}
